import math


def eat_bananas(piles, h):
    lo = 1
    hi = max(piles)

    while lo < hi:
        mid = (lo+hi)//2
        if can_eat(piles, mid, h):
            hi = mid
        else:
            lo = mid + 1

    return lo

def can_eat(piles, k, h):
    return sum(math.ceil(p/k) for p in piles) <= h

print(eat_bananas([3,6,7,11], 8))
print(eat_bananas([30,11,23,4,20], 5))
print(eat_bananas([30,11,23,4,20], 6))